import MyTable from '@/components/MyTable';
import { getResult } from '@/services/sys/attribute';
import { findByLoginList } from '@/services/sys/login';

const columns: (
  | { title: string; dataIndex: string }
  | { title: string; dataIndex: string; search: boolean }
  | {
      title: string;
      dataIndex: string;
      hideInSearch: boolean;
    }
  | {
      title: string;
      dataIndex: string;
      valueType: string;
      hideInSearch: boolean;
    }
  | {
      title: string;
      dataIndex: string;
      valueType: string;
      search: boolean;
    }
  | {
      title: string;
      dataIndex: string;
      valueType: string;
      valueEnum: API.AttributeValue[];
    }
)[] = [
  {
    title: '编号',
    dataIndex: 'id',
    search: false,
  },
  {
    title: '用户名称',
    dataIndex: 'userName',
  },
  {
    title: '登录IP',
    dataIndex: 'ip',
    search: false,
  },
  {
    title: '设备品牌',
    dataIndex: 'brand',
    search: false,
  },
  {
    title: '设备型号',
    dataIndex: 'model',
    search: false,
  },
  {
    title: '系统语言',
    dataIndex: 'language',
    search: false,
  },
  {
    title: '语言',
    dataIndex: 'myLanguage',
    search: false,
  },
  {
    title: '系统版本号',
    dataIndex: 'version',
    search: false,
  },
  {
    title: '版本号',
    dataIndex: 'myVersion',
    search: false,
  },
  {
    title: '发布版本',
    dataIndex: 'myEvnVersion',
    search: false,
  },
  {
    title: '系统及版本',
    dataIndex: 'systemVersion',
    search: false,
  },
  {
    title: '客户端平台',
    dataIndex: 'platform',
    hideInSearch: true,
  },
  {
    title: '登录时间',
    dataIndex: 'createDate',
    valueType: 'dateTime',
    hideInSearch: true,
  },
  {
    title: '更新时间',
    dataIndex: 'updateDate',
    valueType: 'dateTime',
    search: false,
  },
  {
    title: '状态',
    dataIndex: 'state',
    valueType: 'select',
    valueEnum: await getResult('backsatgeloginstate'),
  },
];

const cloneTbale = () => {
  /*  const [pagination, setPagination] = useState<API.Pagination> ( defaultPagination () );
  const {
    run: fetchByLoginList,
    refresh,
    data: dataList,
    loading,
  } = useRequest ( findByLoginList, {
    debounceWait: 100,
    manual: true,
  } );

  useMount ( () => {
    fetchByLoginList ();
  } );*/

  return (
    <MyTable
      search={true}
      request={findByLoginList}
      columns={columns}
    ></MyTable>
  );
};

export default cloneTbale;
